package com.example.demo.designPattern.observer;

import com.google.common.eventbus.EventBus;

/**
 * @Author: xiatian
 * @CreateTime: 2021/11/5 11:17 上午
 * @Description:被观察者
 */
public class EventBusCenter {
    private static EventBus eventBus = new EventBus();
    private EventBusCenter(){

    }
    public static EventBus getInstance(){
        return eventBus;
    }
    //添加观察者
    public static void register(Object obj){
        eventBus.register(obj);
    }
    //移除观察者
    public static void unregister(Object obj) {
        eventBus.unregister(obj);
    }
    //把消息推送给观察者
    public static void post(Object obj){
        eventBus.post(obj);
    }
}
